<?php
namespace App\Services;
use App\Models\MemberMsgModel;

class MemberMsgService{
    /**
     * 插入消息
     * @param array $data
     * @return bool $res
     */
    public function insertmsg($data){
        $res = MemberMsgModel::insert($data);
        return $res;
    }

    /**
     * 获取消息列表
     * @param int $member_id
     * @return object $message_list
     */
    public function getMemberMsgList($member_id){
        $message_list = MemberMsgModel::orderBy('add_date','desc')->orderBy('is_read','asc')->where('member_id',
                $member_id)->get();
        return $message_list;
    }

    /**
     * 更新消息
     * @param int $id
     * @param array $data
     * @return bool $res
     */
    public function updateMsg($id,$data){
        $res = MemberMsgModel::where('id',$id)->update($data);
        return $res;
    }
}